package exame_05_06_2012;

public class Par implements Comparable<Par> {

	private String mat;
	private Veiculo v;

	public Par(Par p) {
		this.mat = p.getMat();
		this.v = p.getV();
	}

	public Par(String mat, Veiculo v) {
		this.mat = mat;
		this.v = v;
	}

	public String getMat() {
		return this.mat;
	}

	public Veiculo getV() {
		return this.v;
	}

	public void setMat(String mat) {
		this.mat = mat;
	}

	public void setV(Veiculo v) {
		this.v = v;
	}

	@Override
	public int compareTo(Par o) {
		return this.getMat().compareTo(o.getMat());
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((mat == null) ? 0 : mat.hashCode());
		result = prime * result + ((v == null) ? 0 : v.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Par))
			return false;
		Par other = (Par) obj;
		if (mat == null) {
			if (other.mat != null)
				return false;
		} else if (!mat.equals(other.mat))
			return false;
		if (v == null) {
			if (other.v != null)
				return false;
		} else if (!v.equals(other.v))
			return false;
		return true;
	}

}
